﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zocono.Infrastructure.Common;
using Zocono.WCS.Domain.DomainRepository;
using Zocono.WCS.Domain.EntityInfo;
using Zocono.WCS.Domain.EquipmentManageDomain;
using Zocono.WCS.Domain.ProgrameDomain;
using Zocono.WCS.Infrastructure.ApllicationDto.DtoWcsManage;
using Zocono.WCS.Infrastructure.Repository;

namespace WcsTestProject
{
    public class AreaGIInit : ISettingInit
    {
        private IServiceProvider _provider;
        private ISnowflake snowflake;
        IProgrameInfoRepository prepository;
        IJobInfoRepository jobRepository;
        IPlcConnectionInfoRepository connRespository;
        IPlcReadDbInfoRepository plcReadRespository;
        IBytesMapObjectInfoRepository bmapRepository;
        IPlcWriteDbInfoRepository writeRepository;
        IPlanarProcessServiceMapInfoRepository mapRepository;

        public AreaGIInit(IServiceProvider provider)
        {
            _provider = provider;
            snowflake = _provider.GetService<ISnowflake>();
            prepository = _provider.GetService<IProgrameInfoRepository>();
            jobRepository = _provider.GetService<IJobInfoRepository>();
            connRespository = _provider.GetService<IPlcConnectionInfoRepository>();
            plcReadRespository = _provider.GetService<IPlcReadDbInfoRepository>();
            bmapRepository = _provider.GetService<IBytesMapObjectInfoRepository>();
            writeRepository = _provider.GetService<IPlcWriteDbInfoRepository>();
            mapRepository = _provider.GetService<IPlanarProcessServiceMapInfoRepository>();
        }
        public async Task<bool> Init()
        {
            var programG = new ProgrameInfo()
            {
                ID = snowflake.GetId(),
                ProgrameCode = "Pro_G",
                ProgrameName = "高温老化一线",
                IsStart = false,
                StartTime = DateTime.Now,
                TickTime = DateTime.Now
            };
            await prepository.InsertAsync(programG);

            var jobList = new List<JobInfo>();
            var jobPlanr = new JobInfo()
            {
                ID = snowflake.GetId(),
                ProgrameCode = "Pro_G",
                JobName = "Job_PlanarG"
            };
            jobList.Add(jobPlanr);
            var jobSc = new JobInfo()
            {
                ID = snowflake.GetId(),
                ProgrameCode = "Pro_G",
                JobName = "Job_SC013"
            };
            jobList.Add(jobSc);
            await jobRepository.InsertRangeAsync(jobList);

            #region PlcConnectionInfo

            var connList = new List<PlcConnectionInfo>();
            var readList = new List<PlcReadDbInfo>();
            var bmapList = new List<BytesMapObjectInfo>();
            var ip10 = new PlcConnectionInfo()
            {
                ID = snowflake.GetId(),
                IP = "172.17.3.10",
                PlcCpuType = S7.Net.CpuType.S71500,
                Rack = 0,
                Slot = 0,
                IsSc = false,
                ScEquipmentCode = ""
            };
            connList.Add(ip10);

            var readIp10Heartbeat = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobPlanr.ID,
                PlcConnectionID = ip10.ID,
                DbCode = 101,
                DbStart = 0,
                DbLength = 2,
                IsHeartbeat = true,
                IsEnable = true,
                ProcessModuleType = "",
                ProcessModuleName = ""
            };
            readList.Add(readIp10Heartbeat);
            var readIp10State = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobPlanr.ID,
                PlcConnectionID = ip10.ID,
                DbCode = 101,
                DbStart = 0,
                DbLength = 2,
                IsHeartbeat = false,
                IsEnable = true,
                ProcessModuleType = "PlcOnlineState",
                ProcessModuleName = "PlcOnlineState"
            };
            readList.Add(readIp10State);
            var readIp10Plc = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobPlanr.ID,
                PlcConnectionID = ip10.ID,
                DbCode = 101,
                DbStart = 2,
                DbLength = 288,
                IsHeartbeat = false,
                IsEnable = true,
                ProcessModuleType = "ProcessModulePlanarService",
                ProcessModuleName = "PlanerG"
            };
            readList.Add(readIp10Plc);
            var readIp10Wcs = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobPlanr.ID,
                PlcConnectionID = ip10.ID,
                DbCode = 102,
                DbStart = 0,
                DbLength = 288,
                IsHeartbeat = false,
                IsEnable = true,
                ProcessModuleType = "ProcessModulePlanarService",
                ProcessModuleName = "PlanerG"
            };
            readList.Add(readIp10Wcs);

            var bmapIp10State = new BytesMapObjectInfo()
            {
                ID = snowflake.GetId(),
                PlcReadDbId = readIp10State.ID,
                BytesIndex = 0,
                BytesLength = 2,
                ObjectLength = 2,
                ObjectName = "PlcOnLineStateBO"
            };
            bmapList.Add(bmapIp10State);
            var bmapIp10Plc = new BytesMapObjectInfo()
            {
                ID = snowflake.GetId(),
                PlcReadDbId = readIp10Plc.ID,
                BytesIndex = 0,
                BytesLength = 288,
                ObjectLength = 48,
                ObjectName = "PlanarGeneralPlcActionBO"
            };
            bmapList.Add(bmapIp10Plc);
            var bmapIp10Wcs = new BytesMapObjectInfo()
            {
                ID = snowflake.GetId(),
                PlcReadDbId = readIp10Wcs.ID,
                BytesIndex = 0,
                BytesLength = 288,
                ObjectLength = 48,
                ObjectName = "PlanarGeneralWcsActionBO"
            };
            bmapList.Add(bmapIp10Wcs);

            var ip30 = new PlcConnectionInfo()
            {
                ID = snowflake.GetId(),
                IP = "172.17.3.30",
                PlcCpuType = S7.Net.CpuType.S71500,
                Rack = 0,
                Slot = 0,
                IsSc = false,
                ScEquipmentCode = ""
            };
            connList.Add(ip30);

            var readIp30Heartbeat = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobPlanr.ID,
                PlcConnectionID = ip30.ID,
                DbCode = 101,
                DbStart = 0,
                DbLength = 2,
                IsHeartbeat = true,
                IsEnable = true,
                ProcessModuleType = "",
                ProcessModuleName = ""
            };
            readList.Add(readIp30Heartbeat);
            var readIp30State = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobPlanr.ID,
                PlcConnectionID = ip30.ID,
                DbCode = 101,
                DbStart = 0,
                DbLength = 2,
                IsHeartbeat = false,
                IsEnable = true,
                ProcessModuleType = "PlcOnlineState",
                ProcessModuleName = "PlcOnlineState"
            };
            readList.Add(readIp30State);
            var readIp30Plc = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobPlanr.ID,
                PlcConnectionID = ip30.ID,
                DbCode = 101,
                DbStart = 2,
                DbLength = 48,
                IsHeartbeat = false,
                IsEnable = true,
                ProcessModuleType = "ProcessModulePlanarService",
                ProcessModuleName = "PlanerG"
            };
            readList.Add(readIp30Plc);
            var readIp30Wcs = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobPlanr.ID,
                PlcConnectionID = ip30.ID,
                DbCode = 102,
                DbStart = 0,
                DbLength = 48,
                IsHeartbeat = false,
                IsEnable = true,
                ProcessModuleType = "ProcessModulePlanarService",
                ProcessModuleName = "PlanerG"
            };
            readList.Add(readIp30Wcs);

            var bmapIp30State = new BytesMapObjectInfo()
            {
                ID = snowflake.GetId(),
                PlcReadDbId = readIp30State.ID,
                BytesIndex = 0,
                BytesLength = 2,
                ObjectLength = 2,
                ObjectName = "PlcOnLineStateBO"
            };
            bmapList.Add(bmapIp30State);
            var bmapIp30Plc = new BytesMapObjectInfo()
            {
                ID = snowflake.GetId(),
                PlcReadDbId = readIp30Plc.ID,
                BytesIndex = 0,
                BytesLength = 48,
                ObjectLength = 48,
                ObjectName = "PlanarGeneralPlcActionBO"
            };
            bmapList.Add(bmapIp30Plc);
            var bmapIp30Wcs = new BytesMapObjectInfo()
            {
                ID = snowflake.GetId(),
                PlcReadDbId = readIp30Wcs.ID,
                BytesIndex = 0,
                BytesLength = 48,
                ObjectLength = 48,
                ObjectName = "PlanarGeneralWcsActionBO"
            };
            bmapList.Add(bmapIp30Wcs);

            var ip181 = new PlcConnectionInfo()
            {
                ID = snowflake.GetId(),
                IP = "172.17.3.181",
                PlcCpuType = S7.Net.CpuType.S71500,
                Rack = 0,
                Slot = 0,
                IsSc = false,
                ScEquipmentCode = ""
            };
            connList.Add(ip181);

            var readIp181Heartbeat = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobPlanr.ID,
                PlcConnectionID = ip181.ID,
                DbCode = 101,
                DbStart = 0,
                DbLength = 2,
                IsHeartbeat = true,
                IsEnable = true,
                ProcessModuleType = "",
                ProcessModuleName = ""
            };
            readList.Add(readIp181Heartbeat);
            var readIp181State = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobPlanr.ID,
                PlcConnectionID = ip181.ID,
                DbCode = 101,
                DbStart = 0,
                DbLength = 2,
                IsHeartbeat = false,
                IsEnable = true,
                ProcessModuleType = "PlcOnlineState",
                ProcessModuleName = "PlcOnlineState"
            };
            readList.Add(readIp181State);
            var readIp181Plc = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobPlanr.ID,
                PlcConnectionID = ip181.ID,
                DbCode = 101,
                DbStart = 2,
                DbLength = 48,
                IsHeartbeat = false,
                IsEnable = true,
                ProcessModuleType = "ProcessModulePlanarService",
                ProcessModuleName = "PlanerI"
            };
            readList.Add(readIp181Plc);
            var readIp181Wcs = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobPlanr.ID,
                PlcConnectionID = ip181.ID,
                DbCode = 102,
                DbStart = 0,
                DbLength = 48,
                IsHeartbeat = false,
                IsEnable = true,
                ProcessModuleType = "ProcessModulePlanarService",
                ProcessModuleName = "PlanerI"
            };
            readList.Add(readIp181Wcs);

            var bmapIp181State = new BytesMapObjectInfo()
            {
                ID = snowflake.GetId(),
                PlcReadDbId = readIp181State.ID,
                BytesIndex = 0,
                BytesLength = 2,
                ObjectLength = 2,
                ObjectName = "PlcOnLineStateBO"
            };
            bmapList.Add(bmapIp181State);
            var bmapIp181Plc = new BytesMapObjectInfo()
            {
                ID = snowflake.GetId(),
                PlcReadDbId = readIp181Plc.ID,
                BytesIndex = 0,
                BytesLength = 48,
                ObjectLength = 48,
                ObjectName = "PlanarGeneralPlcActionBO"
            };
            bmapList.Add(bmapIp181Plc);
            var bmapIp181Wcs = new BytesMapObjectInfo()
            {
                ID = snowflake.GetId(),
                PlcReadDbId = readIp181Wcs.ID,
                BytesIndex = 0,
                BytesLength = 48,
                ObjectLength = 48,
                ObjectName = "PlanarGeneralWcsActionBO"
            };
            bmapList.Add(bmapIp181Wcs);

            var ip65 = new PlcConnectionInfo()
            {
                ID = snowflake.GetId(),
                IP = "172.17.3.65",
                PlcCpuType = S7.Net.CpuType.S71500,
                Rack = 0,
                Slot = 0,
                IsSc = true,
                ScEquipmentCode = "SC013"
            };
            connList.Add(ip65);
            var readIp65Heartbeat = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobSc.ID,
                PlcConnectionID = ip65.ID,
                DbCode = 3,
                DbStart = 0,
                DbLength = 2,
                IsHeartbeat = true,
                IsEnable = true,
                ProcessModuleType = "",
                ProcessModuleName = ""
            };
            readList.Add(readIp65Heartbeat);
            var readIp65Sc = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobSc.ID,
                PlcConnectionID = ip65.ID,
                DbCode = 3,
                DbStart = 0,
                DbLength = 80,
                IsHeartbeat = false,
                IsEnable = true,
                ProcessModuleType = "ProcessModuleScService",
                ProcessModuleName = "SC013ZJN"
            };
            readList.Add(readIp65Sc);
            var bmapIp65ScPlc = new BytesMapObjectInfo()
            {
                ID = snowflake.GetId(),
                PlcReadDbId = readIp65Sc.ID,
                BytesIndex = 0,
                BytesLength = 48,
                ObjectLength = 48,
                ObjectName = "ZJNScMessagePlcActionBO"
            };
            bmapList.Add(bmapIp65ScPlc);
            var bmapIp65ScWcs = new BytesMapObjectInfo()
            {
                ID = snowflake.GetId(),
                PlcReadDbId = readIp65Sc.ID,
                BytesIndex = 48,
                BytesLength = 48,
                ObjectLength = 32,
                ObjectName = "ZJNScMessageWcsActionBO"
            };
            bmapList.Add(bmapIp65ScWcs);

            var ip116 = new PlcConnectionInfo()
            {
                ID = snowflake.GetId(),
                IP = "172.17.3.116",
                PlcCpuType = S7.Net.CpuType.S71500,
                Rack = 0,
                Slot = 0,
                IsSc = true,
                ScEquipmentCode = "SC014"
            };
            connList.Add(ip116);
            var readIp116Heartbeat = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobSc.ID,
                PlcConnectionID = ip116.ID,
                DbCode = 3,
                DbStart = 0,
                DbLength = 2,
                IsHeartbeat = true,
                IsEnable = true,
                ProcessModuleType = "",
                ProcessModuleName = ""
            };
            readList.Add(readIp116Heartbeat);
            var readIp116Sc = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobSc.ID,
                PlcConnectionID = ip116.ID,
                DbCode = 3,
                DbStart = 0,
                DbLength = 80,
                IsHeartbeat = false,
                IsEnable = true,
                ProcessModuleType = "ProcessModuleScService",
                ProcessModuleName = "SC014ZJN"
            };
            readList.Add(readIp116Sc);
            var bmapIp116ScPlc = new BytesMapObjectInfo()
            {
                ID = snowflake.GetId(),
                PlcReadDbId = readIp116Sc.ID,
                BytesIndex = 0,
                BytesLength = 48,
                ObjectLength = 48,
                ObjectName = "ZJNScMessagePlcActionBO"
            };
            bmapList.Add(bmapIp116ScPlc);
            var bmapIp116ScWcs = new BytesMapObjectInfo()
            {
                ID = snowflake.GetId(),
                PlcReadDbId = readIp116Sc.ID,
                BytesIndex = 48,
                BytesLength = 48,
                ObjectLength = 32,
                ObjectName = "ZJNScMessageWcsActionBO"
            };
            bmapList.Add(bmapIp116ScWcs);

            var ip105 = new PlcConnectionInfo()
            {
                ID = snowflake.GetId(),
                IP = "172.17.3.105",
                PlcCpuType = S7.Net.CpuType.S71500,
                Rack = 0,
                Slot = 0,
                IsSc = true,
                ScEquipmentCode = "SC015"
            };
            connList.Add(ip105);
            var readIp105Heartbeat = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobSc.ID,
                PlcConnectionID = ip105.ID,
                DbCode = 3,
                DbStart = 0,
                DbLength = 2,
                IsHeartbeat = true,
                IsEnable = true,
                ProcessModuleType = "",
                ProcessModuleName = ""
            };
            readList.Add(readIp105Heartbeat);
            var readIp105Sc = new PlcReadDbInfo()
            {
                ID = snowflake.GetId(),
                JobID = jobSc.ID,
                PlcConnectionID = ip105.ID,
                DbCode = 3,
                DbStart = 0,
                DbLength = 80,
                IsHeartbeat = false,
                IsEnable = true,
                ProcessModuleType = "ProcessModuleScService",
                ProcessModuleName = "SC015ZJN"
            };
            readList.Add(readIp105Sc);
            var bmapIp105ScPlc = new BytesMapObjectInfo()
            {
                ID = snowflake.GetId(),
                PlcReadDbId = readIp105Sc.ID,
                BytesIndex = 0,
                BytesLength = 48,
                ObjectLength = 48,
                ObjectName = "ZJNScMessagePlcActionBO"
            };
            bmapList.Add(bmapIp105ScPlc);
            var bmapIp105ScWcs = new BytesMapObjectInfo()
            {
                ID = snowflake.GetId(),
                PlcReadDbId = readIp105Sc.ID,
                BytesIndex = 48,
                BytesLength = 48,
                ObjectLength = 32,
                ObjectName = "ZJNScMessageWcsActionBO"
            };
            bmapList.Add(bmapIp105ScWcs);

            await connRespository.InsertRangeAsync(connList);
            await plcReadRespository.InsertRangeAsync(readList);
            await bmapRepository.InsertRangeAsync(bmapList);
            #endregion


            #region PlcWriteDbInfo

            var writeList = new List<PlcWriteDbInfo>();
            writeList.Add(new PlcWriteDbInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1207",
                ObjectType = "PlanarGeneralWriteWcsAction",
                PlcConnectionId = ip10.ID,
                DbCode = 102,
                DbStart = 0
            });
            writeList.Add(new PlcWriteDbInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1209",
                ObjectType = "PlanarGeneralWriteWcsAction",
                PlcConnectionId = ip10.ID,
                DbCode = 102,
                DbStart = 48
            });
            writeList.Add(new PlcWriteDbInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1301",
                ObjectType = "PlanarGeneralWriteWcsAction",
                PlcConnectionId = ip10.ID,
                DbCode = 102,
                DbStart = 144
            });
            writeList.Add(new PlcWriteDbInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1213",
                ObjectType = "PlanarGeneralWriteWcsAction",
                PlcConnectionId = ip10.ID,
                DbCode = 102,
                DbStart = 96
            });
            writeList.Add(new PlcWriteDbInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1307",
                ObjectType = "PlanarGeneralWriteWcsAction",
                PlcConnectionId = ip10.ID,
                DbCode = 102,
                DbStart = 192
            });
            writeList.Add(new PlcWriteDbInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1311",
                ObjectType = "PlanarGeneralWriteWcsAction",
                PlcConnectionId = ip10.ID,
                DbCode = 102,
                DbStart = 240
            });

            writeList.Add(new PlcWriteDbInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G2105",
                ObjectType = "PlanarGeneralWriteWcsAction",
                PlcConnectionId = ip30.ID,
                DbCode = 102,
                DbStart = 0
            });

            writeList.Add(new PlcWriteDbInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "I2108",
                ObjectType = "PlanarGeneralWriteWcsAction",
                PlcConnectionId = ip181.ID,
                DbCode = 102,
                DbStart = 0
            });

            writeList.Add(new PlcWriteDbInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "SC013",
                ObjectType = "ZJNScMessageWriteWcsActionBO",
                PlcConnectionId = ip65.ID,
                DbCode = 3,
                DbStart = 48
            });

            writeList.Add(new PlcWriteDbInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "SC014",
                ObjectType = "ZJNScMessageWriteWcsActionBO",
                PlcConnectionId = ip116.ID,
                DbCode = 3,
                DbStart = 48
            });

            writeList.Add(new PlcWriteDbInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "SC015",
                ObjectType = "ZJNScMessageWriteWcsActionBO",
                PlcConnectionId = ip105.ID,
                DbCode = 3,
                DbStart = 48
            });

            await writeRepository.InsertRangeAsync(writeList);
            #endregion

            #region PlanarProcessServiceMapInfo

            var planarList = new List<PlanarProcessServiceMapInfo>();
            //G1207
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1207",
                PlcActionType = 0,
                WcsActionType = 0,
                PlanarProcessServiceName = "FreeDataService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1207",
                PlcActionType = 1,
                WcsActionType = 0,
                PlanarProcessServiceName = "AisleRequestService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1207",
                PlcActionType = 1,
                WcsActionType = 1,
                PlanarProcessServiceName = "WaitActionService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1207",
                PlcActionType = 0,
                WcsActionType = 1,
                PlanarProcessServiceName = "ClearDataService"
            });

            //G1209
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1209",
                PlcActionType = 0,
                WcsActionType = 0,
                PlanarProcessServiceName = "FreeDataService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1209",
                PlcActionType = 1,
                WcsActionType = 0,
                PlanarProcessServiceName = "ArrivePuService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1209",
                PlcActionType = 1,
                WcsActionType = 1,
                PlanarProcessServiceName = "WaitActionService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1209",
                PlcActionType = 0,
                WcsActionType = 1,
                PlanarProcessServiceName = "ClearDataService"
            });

            //G1301
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1301",
                PlcActionType = 0,
                WcsActionType = 0,
                PlanarProcessServiceName = "FreeDataService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1301",
                PlcActionType = 1,
                WcsActionType = 0,
                PlanarProcessServiceName = "ArriveDoService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1301",
                PlcActionType = 1,
                WcsActionType = 1,
                PlanarProcessServiceName = "WaitActionService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1301",
                PlcActionType = 0,
                WcsActionType = 1,
                PlanarProcessServiceName = "ClearDataService"
            });

            //G1213
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1213",
                PlcActionType = 0,
                WcsActionType = 0,
                PlanarProcessServiceName = "FreeDataService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1213",
                PlcActionType = 1,
                WcsActionType = 0,
                PlanarProcessServiceName = "ArrivePuService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1213",
                PlcActionType = 1,
                WcsActionType = 1,
                PlanarProcessServiceName = "WaitActionService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1213",
                PlcActionType = 0,
                WcsActionType = 1,
                PlanarProcessServiceName = "ClearDataService"
            });

            //G1307
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1307",
                PlcActionType = 0,
                WcsActionType = 0,
                PlanarProcessServiceName = "FreeDataService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1307",
                PlcActionType = 1,
                WcsActionType = 0,
                PlanarProcessServiceName = "ArriveDoService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1307",
                PlcActionType = 1,
                WcsActionType = 1,
                PlanarProcessServiceName = "WaitActionService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1307",
                PlcActionType = 0,
                WcsActionType = 1,
                PlanarProcessServiceName = "ClearDataService"
            });

            //G1311
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1311",
                PlcActionType = 0,
                WcsActionType = 0,
                PlanarProcessServiceName = "FreeDataService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1311",
                PlcActionType = 1,
                WcsActionType = 0,
                PlanarProcessServiceName = "ArrivePuService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1311",
                PlcActionType = 1,
                WcsActionType = 1,
                PlanarProcessServiceName = "WaitActionService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1311",
                PlcActionType = 0,
                WcsActionType = 1,
                PlanarProcessServiceName = "ClearDataService"
            });

            //G2105
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G2105",
                PlcActionType = 0,
                WcsActionType = 0,
                PlanarProcessServiceName = "FreeDataService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G2105",
                PlcActionType = 1,
                WcsActionType = 0,
                PlanarProcessServiceName = "AisleLocationRequestService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G2105",
                PlcActionType = 1,
                WcsActionType = 1,
                PlanarProcessServiceName = "WaitActionService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G2105",
                PlcActionType = 0,
                WcsActionType = 1,
                PlanarProcessServiceName = "ClearDataService"
            });

            //I2108
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "I2108",
                PlcActionType = 0,
                WcsActionType = 0,
                PlanarProcessServiceName = "FreeDataService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "I2108",
                PlcActionType = 1,
                WcsActionType = 0,
                PlanarProcessServiceName = "ArriveDoFinishTaskService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "I2108",
                PlcActionType = 1,
                WcsActionType = 1,
                PlanarProcessServiceName = "WaitActionService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "I2108",
                PlcActionType = 0,
                WcsActionType = 1,
                PlanarProcessServiceName = "ClearDataService"
            });

            await mapRepository.InsertRangeAsync(planarList);
            #endregion

            return true;
        }

        public async Task<bool> InitMap()
        {
            #region PlanarProcessServiceMapInfo

            var planarList = new List<PlanarProcessServiceMapInfo>();
            //G1207
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1207",
                PlcActionType = 0,
                WcsActionType = 0,
                PlanarProcessServiceName = "FreeDataService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1207",
                PlcActionType = 1,
                WcsActionType = 0,
                PlanarProcessServiceName = "AisleRequestService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1207",
                PlcActionType = 1,
                WcsActionType = 1,
                PlanarProcessServiceName = "WaitActionService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1207",
                PlcActionType = 0,
                WcsActionType = 1,
                PlanarProcessServiceName = "ClearDataService"
            });

            //G1209
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1209",
                PlcActionType = 0,
                WcsActionType = 0,
                PlanarProcessServiceName = "FreeDataService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1209",
                PlcActionType = 1,
                WcsActionType = 0,
                PlanarProcessServiceName = "ArrivePuService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1209",
                PlcActionType = 1,
                WcsActionType = 1,
                PlanarProcessServiceName = "WaitActionService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1209",
                PlcActionType = 0,
                WcsActionType = 1,
                PlanarProcessServiceName = "ClearDataService"
            });

            //G1301
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1301",
                PlcActionType = 0,
                WcsActionType = 0,
                PlanarProcessServiceName = "FreeDataService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1301",
                PlcActionType = 1,
                WcsActionType = 0,
                PlanarProcessServiceName = "ArriveDoService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1301",
                PlcActionType = 1,
                WcsActionType = 1,
                PlanarProcessServiceName = "WaitActionService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1301",
                PlcActionType = 0,
                WcsActionType = 1,
                PlanarProcessServiceName = "ClearDataService"
            });

            //G1213
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1213",
                PlcActionType = 0,
                WcsActionType = 0,
                PlanarProcessServiceName = "FreeDataService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1213",
                PlcActionType = 1,
                WcsActionType = 0,
                PlanarProcessServiceName = "ArrivePuService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1213",
                PlcActionType = 1,
                WcsActionType = 1,
                PlanarProcessServiceName = "WaitActionService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1213",
                PlcActionType = 0,
                WcsActionType = 1,
                PlanarProcessServiceName = "ClearDataService"
            });

            //G1307
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1307",
                PlcActionType = 0,
                WcsActionType = 0,
                PlanarProcessServiceName = "FreeDataService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1307",
                PlcActionType = 1,
                WcsActionType = 0,
                PlanarProcessServiceName = "ArriveDoService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1307",
                PlcActionType = 1,
                WcsActionType = 1,
                PlanarProcessServiceName = "WaitActionService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1307",
                PlcActionType = 0,
                WcsActionType = 1,
                PlanarProcessServiceName = "ClearDataService"
            });

            //G1311
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1311",
                PlcActionType = 0,
                WcsActionType = 0,
                PlanarProcessServiceName = "FreeDataService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1311",
                PlcActionType = 1,
                WcsActionType = 0,
                PlanarProcessServiceName = "ArrivePuService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1311",
                PlcActionType = 1,
                WcsActionType = 1,
                PlanarProcessServiceName = "WaitActionService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G1311",
                PlcActionType = 0,
                WcsActionType = 1,
                PlanarProcessServiceName = "ClearDataService"
            });

            //G2105
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G2105",
                PlcActionType = 0,
                WcsActionType = 0,
                PlanarProcessServiceName = "FreeDataService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G2105",
                PlcActionType = 1,
                WcsActionType = 0,
                PlanarProcessServiceName = "AisleLocationRequestService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G2105",
                PlcActionType = 1,
                WcsActionType = 1,
                PlanarProcessServiceName = "WaitActionService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "G2105",
                PlcActionType = 0,
                WcsActionType = 1,
                PlanarProcessServiceName = "ClearDataService"
            });

            //I2108
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "I2108",
                PlcActionType = 0,
                WcsActionType = 0,
                PlanarProcessServiceName = "FreeDataService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "I2108",
                PlcActionType = 1,
                WcsActionType = 0,
                PlanarProcessServiceName = "ArriveDoFinishTaskService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "I2108",
                PlcActionType = 1,
                WcsActionType = 1,
                PlanarProcessServiceName = "WaitActionService"
            });
            planarList.Add(new PlanarProcessServiceMapInfo()
            {
                ID = snowflake.GetId(),
                EquipmentCode = "I2108",
                PlcActionType = 0,
                WcsActionType = 1,
                PlanarProcessServiceName = "ClearDataService"
            });

            await mapRepository.InsertRangeAsync(planarList);
            #endregion

            return true;
        }
    }
}
